unit KRK.Lib.Rtl.Win.AdvApi32;
{$WEAKPACKAGEUNIT ON}
interface

uses Windows;

type
  HCRYPTPROV = type NativeUInt;
  HCRYPTKEY  = type NativeUInt;
  HCRYPTHASH = type NativeUInt;
  ALG_ID     = Cardinal;

  TSHA512Hash = array [0..63] of Byte; // 128 caracteres
  TSHA384Hash = array [0..47] of Byte; // 96 caracteres
  TSHA256Hash = array [0..31] of Byte; // 64 caracteres
  TSHA1Hash   = array [0..19] of Byte; // 40 caracteres
  TMD5Hash    = array [0..15] of Byte; // 32 caracteres
  TMD4Hash    = array [0..15] of Byte; // 32 caracteres
  TMD2Hash    = array [0..15] of Byte; // 32 caracteres

const
  PROV_RSA_AES        = 24;
  CRYPT_VERIFYCONTEXT = $F0000000;
  HP_HASHVAL          = $0002;

  CALG_SHA_512        = $0000800E;
  CALG_SHA_384        = $0000800D;
  CALG_SHA_256        = $0000800C;
  CALG_SHA1           = $00008004;
  CALG_MD5            = $00008003;
  CALG_MD4            = $00008002;
  CALG_MD2            = $00008001;

function CryptAcquireContextW(out phProv: HCRYPTPROV;
                              pszContainer: PWideChar;
                              pszProvider: PWideChar;
                              dwProvType: DWORD;
                              dwFlags: DWORD): BOOL; stdcall; external 'Advapi32.dll';

function CryptReleaseContext(hProv: HCRYPTPROV;
                             dwFlags: DWORD): BOOL; stdcall; external 'Advapi32.dll';

function CryptCreateHash(hProv: HCRYPTPROV;
                         Algid: ALG_ID;
                         hKey: HCRYPTKEY;
                         dwFlags: DWORD;
                         out phHash: HCRYPTHASH): BOOL; stdcall; external 'Advapi32.dll';

function CryptDestroyHash(hHash: HCRYPTHASH): BOOL; stdcall; external 'Advapi32.dll';

function CryptHashData(hHash: HCRYPTHASH;
                       pbData: Pointer;
                       dwDataLen: DWORD;
                       dwFlags: DWORD): BOOL; stdcall; external 'Advapi32.dll';

function CryptGetHashParam(hHash: HCRYPTHASH;
                           dwParam: DWORD;
                           pbData: Pointer;
                           var pdwDataLen: DWORD;
                           dwFlags: DWORD): BOOL; stdcall; external 'Advapi32.dll';

implementation

end.
